﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="TailorEdit.aspx.cs" Inherits="Omabar.CMS.CMS.TailorEdit" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <link rel="stylesheet" type="text/css" href="../CSS/bootstrap_min.css" media="all" />
    <link rel="stylesheet" type="text/css" href="../CSS/bootstrap_responsive_min.css" media="all" />
    <link rel="stylesheet" type="text/css" href="../CSS/Style.css" media="all" />
    <link rel="stylesheet" type="text/css" href="../CSS/todc_bootstrap.css" media="all" />
    <link rel="stylesheet" type="text/css" href="../CSS/Themes.css" media="all" />
    <link rel="stylesheet" type="text/css" href="../CSS/inside.css" media="all" />
    <script type="text/javascript" src="../JavaScript/jquery.1.8.3.js"></script>
    <script type="text/javascript" src="../JavaScript/jquery.cookie.js"></script>
    <script type="text/javascript" src="../JavaScript/bootstrap.js"></script>
    <script type="text/javascript" src="../JavaScript/jquery_validate_min.js"></script>
    <script type="text/javascript" src="../JavaScript/jquery_validate_methods.js"></script>
    <script type="text/javascript" src="../JavaScript/jquery_form_min.js"></script>
    <script type="text/javascript" src="../JavaScript/inside.js"></script>
    <title></title>
    <link rel="shortcut icon" href="../favicon.ico" />
    <!--[if IE 7]><link href="../CSS/font_awesome_ie7.css" rel="stylesheet" /><![endif]-->
    <!--[if lte IE 9]><script src="../JavaScript/watermark.js"></script><![endif]-->
</head>
<body>
    <div id="main">
        <div class="container-fluid">
            <div class="row-fluid">
                <div class="span12">
                    <div class="box">
                        <div class="box-title">
                            <div class="span10">
                                <h3><i class="icon-edit"></i>请编辑定制师信息</h3>
                            </div>
                            <div class="span2"><a class="btn" href="Javascript:window.history.go(-1)">返回</a></div>
                        </div>

                        <div class="box-content">
                            <form action="../Handler/TailorEdit.ashx" method="post" class="form-horizontal form-validate">
                                <div class="control-group">
                                    <label for="TAILOR_NAME" class="control-label">名字：</label>
                                    <div class="controls">
                                        <input type="text" value="<%= this.tailor.TAILOR_NAME %>" name="TAILOR_NAME" id="TAILOR_NAME" class="input-medium" data-rule-required="true"/><span class="maroon">*</span>
                                    </div>
                                </div>

                                <div class="control-group">
                                                <label for="TAILOR_HOT" class="control-label">推荐值(0-100)：</label>
                                                <div class="controls">
                                                    <input type="text" name="TAILOR_HOT"  data-rule-number="true" data-rule-max="100"  class="input-mini" value="<%= this.tailor.TAILOR_HOT %>" />
                                                </div>
                                            </div>

                                <div class="control-group">
                                    <label for="TAILOR_QQ" class="control-label">QQ：</label>
                                    <div class="controls">
                                        <input type="text" value="<%= this.tailor.TAILOR_QQ %>" name="TAILOR_QQ" id="TAILOR_QQ" class="input-medium" data-rule-required="true"/><span class="maroon">*</span>
                                    </div>
                                </div>

                                <div class="control-group">
                                    <label for="TAILOR_PHONE" class="control-label">电话：</label>
                                    <div class="controls">
                                        <input type="text" name="TAILOR_PHONE" value="<%= this.tailor.TAILOR_PHONE %>" id="TAILOR_PHONE" class="input-medium" data-rule-required="true"/><span class="maroon">*</span>
                                    </div>
                                </div>


                                <div class="control-group">
                                    <label for="TAILOR_INFO" class="control-label">介绍：</label>
                                    <div class="controls">
                                        <textarea name="TAILOR_INFO" id="TAILOR_INFO"  style="width: 700px; height: 200px; visibility: hidden;" data-rule-required="true"><%=this.tailor.TAILOR_INFO %></textarea>
                                    </div>
                                    <script>var TAILOR_INFO;</script>
                                    <script src="../KindEditor/kindeditor-min.js"></script>
                                    <script src="../KindEditor/kindeditor.config.js"></script>
                                    <script src="../KindEditor/kindeditor.config-upfile.js"></script>
                                </div>

                                <div class="control-group">
                                    <label for="TAILOR_SPECIALTY" class="control-label">擅长：</label>
                                    <div class="controls">
                                        <textarea name="TAILOR_SPECIALTY" id="TAILOR_SPECIALTY" style="width: 700px; height: 200px; visibility: hidden;" data-rule-required="true"><%=this.tailor.TAILOR_SPECIALTY %></textarea>
                                    </div>
                                    <script>var TAILOR_SPECIALTY;</script>
                                    <script src="../KindEditor/kindeditor-min.js"></script>
                                    <script src="../KindEditor/kindeditor.config.js"></script>
                                    <script src="../KindEditor/kindeditor.config-upfile.js"></script>
                                </div>

                                <div class="control-group">
                                    <label for="TAILOR_CASE" class="control-label">案例：</label>
                                    <div class="controls">
                                        <textarea name="TAILOR_CASE" id="TAILOR_CASE" style="width: 700px; height: 200px; visibility: hidden;" data-rule-required="true"><%=this.tailor.TAILOR_CASE %></textarea>
                                    </div>
                                    <script>var TAILOR_CASE;</script>
                                    <script src="../KindEditor/kindeditor-min.js"></script>
                                    <script src="../KindEditor/kindeditor.config.js"></script>
                                    <script src="../KindEditor/kindeditor.config-upfile.js"></script>
                                </div>

                                <div class="control-group">
                                    <label for="TAILOR_HEAD_IMG" class="control-label">缩略图(圆形)：</label>
                                    <div class="controls">
                                        <div>
                                            <img type="img" src="<%=this.tailor.TAILOR_HEAD_IMG %>" style="max-height: 50px;" />
                                            <input type="hidden" name="TAILOR_HEAD_IMG" value="<%=this.tailor.TAILOR_HEAD_IMG %>"  class="input-medium" />
                                            <a class="btn insertimage">选择图片</a>
                                        </div>
                                    </div>
                                </div>

                                <div class="control-group">
                                    <label for="picurl" class="control-label">个人照片：</label>
                                    <div class="controls">
                                        <table class="dataTable-mini" id="photo_table">
                                            <%foreach (var photo in this.photos)
                                              {%>
                                            <tr id="photo_tabletr<%=photo.PHOTO_ID%>">
                                                <td>
                                                    <input type="hidden" value="<%=photo.PHOTO_ID%>" name="photo[0][]" /><img src="<%=photo.PHOTO_URL%>" style="width: 40px; height: 30px; margin-right: 20px;" /><%=photo.PHOTO_NAME%></td>
                                                <td><a class="btn btn-mini del" href="javascript:void(0)"><i class="icon-remove"></i></a></td>
                                            </tr>
                                            <%}%>
                                        </table>
                                        <button id="btnAddPhoto" type="button" rel="photo_table" class="btn add-on">添加</button><span style="color: red;" class="help-inline">最多添加9个</span>
                                    </div>
                                </div>

                                <div class="form-actions">
                                    <input type="hidden" name="TAILOR_ID" value="<%=tailor_id%>"/>
                                    <button type="submit" class="btn btn-primary">保存</button>
                                    <a class="btn" href="Javascript:window.history.go(-1)">取消</a>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <!--图片选择器-->
        <div id="photoModel" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                        <h4 class="modal-title"><i class="icon-table"></i>选择图片集</h4>
                    </div>
                    <div class="modal-body">
                        <div class="row-fluid">
                            图片标题：
                            <input name="photoKey" id="photoKey" type="text" style="margin-bottom: 0px;" class="input-medium" placeholder="输入标题进行查找" />
                            <button type="button" class="btn" id="btnFindPhoto"><strong>查找</strong></button>
                        </div>
                        <p></p>
                        <div class="row-fluid">
                            <input type="checkbox" id="chkallPhoto" name="chkallPhoto" />
                            全选　共有 <span class="red" id="count_num_photo">0</span> 条符合条件
                            <button type="button" class="btn btn-mini" id="p_page_photo"><strong>上一页</strong></button>
                            <span id="p_page_str">第1页/共1页</span>
                            <button type="button" class="btn btn-mini" id="n_page_photo"><strong>下一页</strong></button>
                            <ul class="unstyled list-li-border" id="data-photo-list"></ul>
                        </div>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-primary" data-dismiss="modal">确定</button>
                    </div>
                    <script type="text/javascript">
                        $(document).ready(function () {
                            var _photodata_table_id;
                            var _isosophoto = false;
                            $("#chkallPhoto").click(function () {
                                var $idsCheck = $("#data-photo-list input[name='check']")
                                var $this = $(this);
                                if ($this.attr("checked")) {
                                    $idsCheck.attr("checked", true);
                                } else {
                                    $idsCheck.attr("checked", false);
                                }
                                $idsCheck.each(function () {
                                    _tr($(this));
                                });

                            });
                            $("#btnFindPhoto").click(function () {
                                _isosophoto = true;
                                $("#btnFindPhoto").attr("disabled", ""); _page(1)
                            });
                            $("#data-photo-list input[name='check']").live("click", function () { _tr($(this)); });
                            var _tr = function (_t) {
                                var $this = _t;
                                var $title = $this.attr("t");
                                var $img = $this.attr("img");
                                var $id = $this.val();
                                var $selecttr = $("#" + _photodata_table_id + "tr" + $id + "");
                                if ($this.attr("checked")) {
                                    if ($selecttr.length == 0 && $("#" + _photodata_table_id + " tr").length < 9) {
                                        var t = (_photodata_table_id == "photo_table") ? "photo[0][]" : "photo[1][]";
                                        var _trtmp = "<tr id='" + _photodata_table_id + "tr" + $id + "'><td><input type='hidden' name='" + t + "'  value='" + $id + "' /><img src='" + $img + "' style='width:40px;height:30px;margin-right:20px;'/>" + $title + "</td><td><a href='javascript:void(0)' class='btn btn-mini del'><i class='icon-remove'></i></a></td></tr>";
                                        $("#" + _photodata_table_id + "").append(_trtmp);
                                    }

                                } else {
                                    $selecttr.remove();
                                }
                            }
                            //删除
                            $("table.dataTable-mini .del").live("click", function () {
                                $(this).parent().parent().remove();
                            });
                            $("#btnAddPhoto").click(function (e) {
                                e.preventDefault();
                                _photodata_table_id = $(this).attr("rel");
                                $('#photoModel').modal('show');
                                $("#chkallPhoto").attr("checked", false);
                                _page(1);
                            });
                            $("#p_page_photo").click(function () {
                                if (_this_page - 1 > 0) {
                                    _this_page--;
                                    _page(_this_page);
                                }
                            });
                            $("#n_page_photo").click(function () {
                                if (_this_page + 1 <= _this_page_count) {
                                    _this_page++;
                                    _page(_this_page);
                                }
                            });
                            var _this_page = 1;//当前页
                            var _this_page_count = 0;//总页数
                            var _page = function (_index) {
                                var photoKey;
                                if (_isosophoto) {
                                    photoKey = $("#photoKey").val();
                                }

                                $.get("../Handler/PhotoRead.ashx",
                                    { "key": photoKey, "page": _index, },
                                    function (data, textStatus) {
                                        $("#data-photo-list").html("");
                                        $.each(data.list, function (index, item) {
                                            var _li_tmp = '<li><label><input type="checkbox" name="check" img="' + item.PHOTO_URL + '"  t="' + item.PHOTO_NAME + '" value="' + item.PHOTO_ID + '" /><img src="' + item.PHOTO_URL + '" style="width:40px;height:30px;margin:0 20px" />' + item.PHOTO_NAME + '</label></li>';
                                            $("#data-photo-list").append(_li_tmp);
                                        });

                                        _this_page_count = data.count;
                                        $("#count_num_photo").text(data.total);
                                        $("#p_page_str").text("第" + _this_page + "页/共" + _this_page_count + "页");
                                        $("#btnFindPhoto").removeAttr("disabled")
                                    }, "json");
                            }



                        })


                        KindEditor.ready(function (K) {
                            var TAILOR_INFO = K.create('#TAILOR_INFO', {
                                items: [
                                'source', '|', 'undo', 'redo', '|', 'preview', 'print', 'template', 'cut', 'copy', 'paste',
                                'plainpaste', 'wordpaste', '|', 'justifyleft', 'justifycenter', 'justifyright',
                                'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'subscript',
                                'superscript', 'clearhtml', 'quickformat', 'selectall', '|', 'fullscreen', '/',
                                'formatblock', 'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold',
                                'italic', 'underline', 'strikethrough', 'lineheight', 'removeformat', '|', 'image'
                                 , 'table', 'hr', 'emoticons', 'baidumap', 'code', 'pagebreak',
                                'link', 'unlink', 'music', 'video'
                                ],
                                themeType: "simple",
                                allowFileManager: true,
                                allowFlashUpload: false,
                                allowMediaUpload: false,
                                allowFileUpload: false
                            });

                            var TAILOR_SPECIALTY = K.create('#TAILOR_SPECIALTY', {
                                items: [
                                'source', '|', 'undo', 'redo', '|', 'preview', 'print', 'template', 'cut', 'copy', 'paste',
                                'plainpaste', 'wordpaste', '|', 'justifyleft', 'justifycenter', 'justifyright',
                                'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'subscript',
                                'superscript', 'clearhtml', 'quickformat', 'selectall', '|', 'fullscreen', '/',
                                'formatblock', 'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold',
                                'italic', 'underline', 'strikethrough', 'lineheight', 'removeformat', '|', 'image'
                                 , 'table', 'hr', 'emoticons', 'baidumap', 'code', 'pagebreak',
                                'link', 'unlink', 'music', 'video'
                                ],
                                themeType: "simple",
                                allowFileManager: true,
                                allowFlashUpload: false,
                                allowMediaUpload: false,
                                allowFileUpload: false
                            });

                            var TAILOR_CASE = K.create('#TAILOR_CASE', {
                                items: [
                                'source', '|', 'undo', 'redo', '|', 'preview', 'print', 'template', 'cut', 'copy', 'paste',
                                'plainpaste', 'wordpaste', '|', 'justifyleft', 'justifycenter', 'justifyright',
                                'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'subscript',
                                'superscript', 'clearhtml', 'quickformat', 'selectall', '|', 'fullscreen', '/',
                                'formatblock', 'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold',
                                'italic', 'underline', 'strikethrough', 'lineheight', 'removeformat', '|', 'image'
                                 , 'table', 'hr', 'emoticons', 'baidumap', 'code', 'pagebreak',
                                'link', 'unlink', 'music', 'video'
                                ],
                                themeType: "simple",
                                allowFileManager: true,
                                allowFlashUpload: false,
                                allowMediaUpload: false,
                                allowFileUpload: false
                            });
                        });

                        KindEditor.ready(function (K) {
                            var editor = K.editor({
                                themeType: 'simple',
                                allowFileManager: true
                            });
                            $('a.insertimage').live('click', function (e) {
                                editor.loadPlugin('smimage', function () {
                                    editor.plugin.imageDialog({
                                        imageUrl: $(e.target).prev().val(),
                                        clickFn: function (url, title, width, height, border, align) {
                                            $(e.target).prev().val(url);
                                            if ('img' == $(e.target).prev().prev().attr('type')) {
                                                $(e.target).prev().hide();
                                                $(e.target).prev().prev().attr('src', url);
                                                $(e.target).prev().prev().show();
                                            }
                                            editor.hideDialog();
                                        }
                                    });
                                });
                            });
                        });
                    </script>
                </div>
            </div>
        </div>
    </div>
</body>
</html>